package com.lyj.common.core.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.lyj.common.core.domain.R;
import com.lyj.common.core.domain.TableDataInfo;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-08-17
 * Time: 22:55
 */
public class BaseController {
    public R<Void> toR(int rows){
        return rows > 0 ? R.ok() : R.fail();
    }
    public R<Void> toR(boolean res){
        return res ? R.ok() : R.fail();
    }

    public TableDataInfo getTableDataInfo(List<?> list){
        if(CollectionUtil.isEmpty(list)){
            return TableDataInfo.empty();
        }

        return TableDataInfo.success(list,new PageInfo<>(list).getTotal());
    }
}
